//
//  ScrollViewViewController.m
//  SDKSample
//
//  Created by 小肥羊 on 15/5/21.
//  Copyright (c) 2015年 Zhu‘s Game House. All rights reserved.
//

#import "ScrollViewViewController.h"

@implementation ScrollViewViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.mainScorllView = [[CycleScrollView alloc] initWithFrame:CGRectMake(50, 100, 200, 100) animationDuration:2];
    self.mainScorllView.backgroundColor = [[UIColor purpleColor] colorWithAlphaComponent:0.1];
    
    self.xfyCrollView = [[XFYScrollView alloc] initWithFrame:CGRectMake(0, 210, self.view.bounds.size.width, 180) animationDuration:2];
    self.xfyCrollView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.xfyCrollView.clickScrollViewDelegate = self;
    [self.view addSubview:self.xfyCrollView];
}

- (IBAction)addView:(UIButton *)sender {
    for(UIView *view in [self.view subviews])
    {
        if ([view isKindOfClass:[CycleScrollView class]]) {
            [view removeFromSuperview];
        }
    }
    NSMutableArray *viewsArray = [@[] mutableCopy];
    NSArray *colorArray = @[[UIColor cyanColor],[UIColor blueColor],[UIColor greenColor],[UIColor yellowColor],[UIColor purpleColor]];
    for (int i = 0; i < 5; ++i) {
        UILabel *tempLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
        tempLabel.backgroundColor = [(UIColor *)[colorArray objectAtIndex:i] colorWithAlphaComponent:0.5];
        [viewsArray addObject:tempLabel];
    }
    __weak typeof(self) _WeakSelf = self;
    self.mainScorllView.fetchContentViewAtIndex = ^UIView *(NSInteger pageIndex){
        return viewsArray[pageIndex];
    };
    self.mainScorllView.totalPagesCount = ^NSInteger(void){
        return 5;
    };
    self.mainScorllView.TapActionBlock = ^(NSInteger pageIndex){
        _WeakSelf.areaId = @"asf";
        NSLog(@"点击了第%@个",@(pageIndex));
    };
    [self.view addSubview:self.mainScorllView];
}

- (IBAction)addXFYView:(UIButton *)sender {
    NSLog(@"我要自定义自己的ScorllView");
    NSMutableArray *viewsArray = [@[] mutableCopy];
    NSArray *colorArray = @[[UIColor cyanColor],[UIColor blueColor],[UIColor greenColor],[UIColor yellowColor],[UIColor purpleColor]];
    for (int i = 0; i < 5; ++i) {
        UILabel *tempLabel = [[UILabel alloc] init];
        [tempLabel setText:[[NSString alloc] initWithFormat:@"我是:%d",i]];
        tempLabel.backgroundColor = [(UIColor *)[colorArray objectAtIndex:i] colorWithAlphaComponent:1];
        [viewsArray addObject:tempLabel];
    }
    self.xfyCrollView.contentViews = viewsArray;
}

- (void)clickScrollView:(XFYScrollView *)scrollView PageIndex:(NSInteger)pageIndex
{
    NSLog(@"点击的是%d",pageIndex);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
